package com.xckj.cycling.model

import android.os.Parcelable
import kotlinx.parcelize.Parcelize

@Parcelize
data class RouteLineListModel(
    var list: MutableList<RouteLineModel>? = null,
    var detail: RouteLineModel? = null
) : Parcelable

@Parcelize
data class RouteLineModel(
    var id: Int = 1,
    var userid: Int = 3,
    var name: String? = null,
    var startlng: String? = null,
    var startlat: String? = null,
    var endlng: String? = null,
    var endlat: String? = null,
    var actualdistance: Long = 0,
    var mileage: String? = "",
    var distance: String? = null,
    var estimatedDuration: Long = 0L,
    var actualDuration: Long = 0L,
    var status: Int = 1,
//    var json: String? = null,
    var creattime: String? = null,
    var iscollection: Boolean = false,
    var ispraise: Boolean = false,
    var lineimg: String? = null,
    var fulllineimg: String? = null,
    var collectionnum: Int = 0,

    var endpost: String? = null,
    var praisenum: Int = 0,
    var content: String? = null,
    var calories: String? = null, var climb: String? = null,
    var comments: List<Comment>? = null,
    var highly: ChartValue? = null,
    var isOrigin: Boolean = false,  //是否 导航到起点
    var isStart: Boolean = false,//是否 开始骑行
    var json: List<RoutePoint>? = null,
    var imgs: MutableList<String>? = null,
    var fullimgs: MutableList<String>? = null,
    var isuser: Int = 0,
    var ground_text: String? = null,
    var cid: String? = null
) : Parcelable {
    val fullimg: String?
        get() {
            return if (null != imgs && imgs!!.size > 0) {
                imgs!![0]
            } else {
                fulllineimg
            }
//            return imgs?.firstOrNull() ?: fulllineimg ?: (imgs?.firstOrNull() ?: lineimg)
        }

    val allImages: MutableList<String>
        get() {
            return when {
                fullimgs.isNullOrEmpty() -> {
                    arrayListOf(fulllineimg + "")
                }

                else -> {
                    fullimgs!!
                }
            }
        }

    val allShareImages: MutableList<String>
        get() {
            return when {
                imgs.isNullOrEmpty() -> {
                    arrayListOf(fulllineimg + "")
                }

                else -> {
                    arrayListOf(fulllineimg ?: "").plus(imgs?.toMutableList() ?: arrayListOf())
                        .toMutableList()
                }
            }
        }
}

@Parcelize
data class Comment(
    var id: Int = 0,
    var userId: Int = 0,
    var privateid: Int = 0,
    var content: String? = null,
    var createtime: String? = null,
    var user: CommentUser? = null,
    var rec: List<Comment>? = null //盖楼评论
) : Parcelable

@Parcelize
data class CommentUser(
    var nickname: String? = null,
    var name: String? = null,
    var avatar: String? = null
) : Parcelable

@Parcelize
data class RoutePoint(var lng: Double = 0.0, var lat: Double = 0.0) : Parcelable